<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var arr = function (nums) {
      let ans = 0, min = Infinity;
      const len = nums.length;
      const arr = new Array(len).fill(0);
      arr[0] = nums[0];
      for (let i = 1; i < len; i++) {
        arr[i] = arr[i - 1] + nums[i];
      }
      for (let i = 0; i < len; i++) {
        let cur = (arr[i] / (i + 1) | 0) - ((arr[len - 1] - arr[i]) / (len - i - 1) | 0);
        cur = Math.abs(cur);
        if (cur < min) {
          ans = i;
          min = cur;
        }
      }
      return ans;
    };
    console.log(arr([2, 5, 3, 9, 5, 3]));
  </script>
</body>

</html>